<?php
 require "../document/class_corpus.php";
 require "../document/class_document.php";
 require "../document/class_document_xml.php";

 require "../files/tool_files_dirs.php";
 require "../misc/class_tag.php";

 require "../tree/class_tree.php";
 require "../tree/class_tree_xhtml.php";
 require "../tree/class_structure.php";
 require "../tree/tool_tree.php";

 require "../array/tool_array.php";

 require "../string/tool_string.php";
 require "../string/class_segment.php";

 require "../pdo/class_sql_document.php";

$exp = new sql_experience("align_ecr_selected");
$array_obj_sql = $exp->reader_experience();

$res_lg_bloc_word = array();

//récupérer les langues
$array_lg = $array_obj_sql['sql_document']->reader_all_lg();

//pour chaque langue, récupérer les id_bloc associés
foreach($array_lg as $info_lg){
  $lg = $info_lg[0];
  $res[$lg] = array();
  $array_id_bloc = $array_obj_sql['sql_bloc']->reader_lg2id_bloc($lg);
  //pour chaque bloc, récupérer les id_words associés
  foreach($array_id_bloc as $info_bloc){
    $id_bloc = $info_bloc[0];
    // récupérer les id_word associés;
    $array_info_word = $array_obj_sql['sql_word']->reader_id_bloc2info_word($id_bloc);
    $nb_word = count($array_info_word);
    $res[$lg][$id_bloc] = 0;
    foreach($array_info_word as $info){
      $res[$lg][$id_bloc]++ ;
    }
  }
}

$lg_min_max = array();
foreach($res as $lg=>$array_info_bloc){
  $lg_min_max[$lg] = array('max'=>0,'min'=>10000000);
  foreach($array_info_bloc as $id_bloc=>$nb_words){
    if($nb_words > $lg_min_max[$lg]['max']){
      $lg_min_max[$lg]['max'] = $nb_words;
    }
    if($nb_words < $lg_min_max[$lg]['min'] and $nb_words > 0){
      $lg_min_max[$lg]['min'] = $nb_words;
    }
  }
}


print_r($lg_min_max);
?>
